// pages/tools/ertong/csjbxx.js
var _$ = require("../../../common/wxjs/wx_ajax");
const url = "et_yejl";
Page({
    /**
     * 页面的初始数据
     */
    data: {
        uesrtoken: null,
        formdata: {
            "day": '',
            "month": '',
            "year1": '',
            "year2": ''
        }
    },
    // 请求数据
    getdata: function(val) {
        var that = this;
        var litToken = val;
        var dataobj = {litToken };
        var methods = "GET";
        var header = "application/json";
        wx.showLoading({
            title: '加载中',
        })
        _$.sendRrquest(url, methods, dataobj, header)
            .then(function(response) {
              console.log(response)
                setTimeout(function() {
                    wx.hideLoading()
                }, 1000)
                that.setData({
                  "formdata.day": response.data.data.day,
                  "formdata.month": response.data.data.month,
                  "formdata.year1": response.data.data.year_1,
                  "formdata.year2": response.data.data.year_2
                });
            }, function(error) {
                setTimeout(function() {
                    wx.hideLoading()
                }, 2000)
                wx.showToast({
                    title: '网络错误，请稍后再试',
                    duration: 2000
                })
                setTimeout(function() {
                    wx.hideToast()
                }, 2000)
                console.log(error);
            });
    },
    // 点击跳转
    dayContAdd: function(e) {
        var nianling = e.currentTarget.dataset.nianling;
        var htmlsrc
        htmlsrc = "./dataEdit/byjladd?nianling=" + nianling
        wx.navigateTo({
            url: htmlsrc
        })
    },
    suiContAdd: function(e) {
        var nianling = e.currentTarget.dataset.nianling;
        var pagename = e.currentTarget.dataset.pagename;
        var htmlsrc
        htmlsrc = "./dataEdit/" + pagename + "?nianling=" + nianling
        wx.navigateTo({
            url: htmlsrc
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {
     
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
      var that = this
      wx.getStorage({
        key: 'token',
        success: function (res) {
          that.setData({
            uesrtoken: res.data
          })
          that.getdata(res.data)
        }
      })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },
})